package ceet.ac.cn.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import ceet.ac.cn.model.teacher;

public class TeacherDao {
	public teacher selectteachetid(int teacherid){  //根据ID进行查询
        Connection conn = DbHelper.getConnection();
        String sql  = "select * from teacher where teacherid = "+teacherid;
        teacher teacher = null;
        try {
            PreparedStatement pst = conn.prepareStatement(sql);
            ResultSet rst = pst.executeQuery();
            while (rst.next()) {
                teacher = new teacher();
                teacher.setTeacherid(rst.getInt("teacherid"));
                teacher.setTeacherg(rst.getString("teacherg"));
                teacher.setTeachername(rst.getString("teachername"));
                teacher.setTeachery(rst.getString("teachery"));
                teacher.setTeachert(rst.getString("teachert"));
            }
            rst.close();
            pst.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return teacher;  //返回
    }

}
